package cn.wolfcode.p2p.controller;

import cn.wolfcode.p2p.base.anno.NeedLogin;
import cn.wolfcode.p2p.base.domain.IpLog;
import cn.wolfcode.p2p.base.query.IpLogQuery;
import cn.wolfcode.p2p.base.service.IIpLogService;
import cn.wolfcode.p2p.util.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 登录记录控制器
 */
@Controller
public class IpLogController {
    @Autowired
    private IIpLogService ipLogService;

    /**
     * 登录日志页面
     */
    @RequestMapping("ipLog")
    @NeedLogin
    public String ipLog(@ModelAttribute("qo") IpLogQuery qo, Model model){
        //只查询自己的登录日志
        qo.setUsername(UserContext.getCurrentUser().getUsername());
        model.addAttribute("pageInfo", ipLogService.query(qo));
        return "iplog/iplog_list";
    }
}
